package org.example.sort;

import java.util.Arrays;

/**
 * 选择排序
 */
public class SelectSort extends AbstractSort{

    @Override
    public void sort(int[] datas){
//        System.out.println("初始化数据"+ Arrays.toString(datas));
        int index;
        int tmp;
        for(int i = 0; i < (datas.length-1); i++){
            index = i;
            for(int j = (i+1); j <datas.length; j++){
                if(datas[index] > datas[j]){
                    index = j;
                }
            }
            tmp = datas[index];
            datas[index] = datas[i];
            datas[i] = tmp;
        }
//        System.out.println("排序后数据"+ Arrays.toString(datas));
    }
}
